package com.fit.hibernate;

import java.io.Serializable;
import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.Session;

import com.fit.beans.ClientBean;
import com.fit.interfaces.ClientI;
import com.fit.service.ClientsI;

public class ClientsServiceHibernate implements ClientsI {

	private Session session;
	
	
	public ClientsServiceHibernate(Session session) {
		
		this.session = session;
	}

	public ClientI save(ClientI user) {
		// TODO Auto-generated method stub
		return (ClientI) session.get(ClientBean.class, session.save(user));
	}

	public Collection<ClientI> retrive() {
		Criteria criteria = session.createCriteria(ClientBean.class);
		return criteria.list();
	}

	public ClientI retriveSingleUser(Serializable userId) {
		
		return (ClientI) session.get(ClientBean.class, userId);
	}

}
